﻿using System;
using System.Linq.Expressions;
using System.Web.Mvc;

namespace MvcBootstrapTimepicker
{
    public static class TimePickerHtmlExtension
    {
        /// <summary>
        /// Renders a time picker element by using the specified Html helper and form field name.
        /// </summary>
        /// <param name="helper">Html helper</param>
        /// <param name="name">Form field name</param>
        /// <returns></returns>
        public static BootstrapTimePicker<TModel> BootstrapTimePicker<TModel>(this HtmlHelper<TModel> helper, string name)
        {
            return new BootstrapTimePicker<TModel>(helper, name);
        }

        /// <summary>
        /// Renders a time picker element for the object represented by the expression.
        /// </summary>
        /// <param name="helper">Html helper</param>
        /// <param name="expression">Model expression</param>
        /// <returns></returns>
        public static BootstrapTimePicker<TModel> BootstrapTimePickerFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression)
        {
            return new BootstrapTimePicker<TModel>(helper, ExpressionHelper.GetExpressionText(expression),
                ModelMetadata.FromLambdaExpression(expression, helper.ViewData));
        }
    }
}